﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace T12OOP
{
    class GameValue
    {
        private int hp;//健康值
        private int mp;//魔法值
        private int sp;//精力值

        public int Hp { get { return hp; }set { hp = value; } }
        public int Mp { get { return mp; }set { mp = value; } }
        public int Sp { get { return sp; }set { sp = value; } }

        public override string ToString()
        {
            return string.Format("健康值:{0},魔法值:{1},精力值:{2}",hp,mp,sp);
        }

        public static GameValue operator +(GameValue gv1, GameValue gv2)
        {
            //定义了在GameValue对象上"+"号的运算规则
            GameValue _gv = new GameValue();
            _gv.hp = gv1.hp + gv2.hp;
            _gv.mp = gv1.mp + gv2.mp;
            _gv.sp = gv1.sp + gv2.sp;

            return _gv;
        }
    }
}
